<?php


    function Print_excel($all_project_information){
    
        import("Org.Util.PHPExcel");
        import("Org.Util.PHPExcel.Writer.Excel2007");
        import("Org.Util.PHPExcel.Writer.Excel5");
        import("Org.Util.PHPExcel.IOFactory");
        
        $objPHPExcel = new \PHPExcel();
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.'1', '编号')
                                           ->setCellValue('B'.'1', '项目编号')
                                            ->setCellValue('C'.'1', '项目名')
                                            ->setCellValue('D'.'1', '负责人名')
                                             ->setCellValue('E'.'1', '用户名')
                                            ->setCellValue('F'.'1', '学号')
                                            ->setCellValue('G'.'1', '真实姓名')
                                            ->setCellValue('H'.'1', '成绩')
                                            ->setCellValue('I'.'1','用户ID');
                                          
                                           


        $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('A')->setAutoSize(true);
        $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('B')->setAutoSize(true);
        $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('C')->setAutoSize(true);
        $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('D')->setAutoSize(true);
        $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('E')->setAutoSize(true);
        $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('F')->setAutoSize(true);
         $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('G')->setAutoSize(true);
        $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('H')->setAutoSize(true);
        $objPHPExcel->getActiveSheet()->getColumnDimension('I')->setVisible(false); 
   
        


     
      
         foreach($all_project_information as $k => $v){
            
            $num=$k+2;
            switch ($v['isbid']){
                case 0: $isbid = "不招标"; break;
                case 1: $isbid = "招标中"; break;
                case 2: $isbid = "停止招标"; break;
            }
            switch ($v['ischecked']){
                case 0: $ischecked = "未审核"; break;
                case 1: $ischecked = "审核通过"; break;
                case 2: $ischecked = "审核未通过"; break;
            }
            $objPHPExcel->setActiveSheetIndex(0) 
                        ->setCellValue('A'.$num, $num-1)
                        ->setCellValue('B'.$num, $v['id'])
                        ->setCellValue('C'.$num, $v['name'])
                         ->setCellValue('D'.$num, $v['leader'])
                         ->setCellValue('E'.$num, $v['username'])
                          ->setCellValue('F'.$num, $v['stunum'])
                           ->setCellValue('G'.$num, $v['realname'])
                            ->setCellValue('H'.$num, $v['0'])
                           ->setCellValue('I'.$num, $v['uid']);
                          
                  
                  
                        

       

}
 $this_time = date('Y-m-d', time());
        $objPHPExcel->getActiveSheet()->setTitle("$this_time");
        $objPHPExcel->setActiveSheetIndex(0);
        header('Content-Type: application/vnd.ms-excel');
        header('Content-Disposition: attachment;filename="'.$this_time._全部导出数据.'.xls"');
        header('Cache-Control: max-age=0');
        ob_clean();
        flush();

        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
        $objWriter->save('php://output');
        exit;
    
}
?>


　　　　


 

